<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生安全中心</title>
    <style>
        body {
            font-family: 'Helvetica Neue', Arial, sans-serif;
            margin: 0;
            padding: 0;
            line-height: 1.6;
            color: #333;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        header {
            background-color: #1a5f7a;
            color: white;
            padding: 1rem 0;
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
        }
        nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .logo {
            font-size: 1.5rem;
            font-weight: bold;
        }
        .menu {
            list-style: none;
            display: flex;
        }
        .menu li {
            margin-left: 20px;
        }
        .menu a {
            color: white;
            text-decoration: none;
            transition: color 0.3s ease;
        }
        .menu a:hover {
            color: #a8dadc;
        }
        .carousel {
            margin-top: 60px;
            position: relative;
            height: 500px;
            overflow: hidden;
        }
        .carousel-item {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            transition: opacity 0.5s ease-in-out;
            background-size: cover;
            background-position: center;
        }
        .carousel-item.active {
            opacity: 1;
        }
        .carousel-content {
            position: absolute;
            bottom: 20px;
            left: 20px;
            color: white;
            background-color: rgba(0, 0, 0, 0.7);
            padding: 20px;
            border-radius: 5px;
        }
        .safety-topics {
            display: flex;
            justify-content: space-between;
            margin: 2rem 0;
        }
        .safety-topic {
            flex-basis: 30%;
            background-color: #f1faee;
            padding: 1.5rem;
            border-radius: 10px;
            text-align: center;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }
        .safety-topic:hover {
            transform: translateY(-5px);
        }
        .announcements, .news {
            background-color: #a8dadc;
            padding: 2rem;
            margin-bottom: 2rem;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .news-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }
        .news-item {
            background-color: white;
            padding: 1rem;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .knowledge-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }
        .card {
            background-color: #f1faee;
            padding: 1.5rem;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
        }
        footer {
            background-color: #1d3557;
            color: white;
            text-align: center;
            padding: 2rem 0;
            margin-top: 2rem;
        }
        .chat-button {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: #1a5f7a;
            color: white;
            border: none;
            padding: 15px 25px;
            border-radius: 30px;
            cursor: pointer;
            font-size: 1rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: background-color 0.3s ease;
        }
        .chat-button:hover {
            background-color: #457b9d;
        }
        .chat-window {
            display: none;
            position: fixed;
            bottom: 80px;
            right: 20px;
            width: 300px;
            height: 400px;
            background-color: white;
            border: 1px solid #ddd;
            border-radius: 10px;
            padding: 1rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>
    <header>
        <div class="container">
            <nav>
                <div class="logo">学生安全中心</div>
                <ul class="menu">
                    <li><a href="#home">首页</a></li>
                    <li><a href="#courses">安全课程</a></li>
                    <li><a href="#guidelines">安全指南</a></li>
                    <li><a href="#about">关于我们</a></li>
                </ul>
            </nav>
        </div>
    </header>

    <main>
        <section class="carousel">
            <div class="carousel-item active" style="background-image: url('https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');">
                <div class="carousel-content">
                    <h2>网络安全</h2>
                    <p>保护你的数字生活，远离网络威胁</p>
                </div>
            </div>
            <div class="carousel-item" style="background-image: url('https://images.unsplash.com/photo-1587654780291-39c9404d746b?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');">
                <div class="carousel-content">
                    <h2>防火安全</h2>
                    <p>了解消防知识，确保生命财产安全</p>
                </div>
            </div>
            <div class="carousel-item" style="background-image: url('https://images.unsplash.com/photo-1605493041208-b8a7f2c0c092?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');">
                <div class="carousel-content">
                    <h2>用电安全</h2>
                    <p>安全用电，预防触电和火灾事故</p>
                </div>
            </div>
        </section>

        <div class="container">
            <section class="safety-topics">
                <div class="safety-topic">
                    <h3>网络安全</h3>
                    <p>保护个人信息，防范网络诈骗，学习安全上网技巧</p>
                    <a href="#network-safety">了解更多</a>
                </div>
                <div class="safety-topic">
                    <h3>防火安全</h3>
                    <p>掌握消防知识，学习火灾逃生技能，提高安全意识</p>
                    <a href="#fire-safety">了解更多</a>
                </div>
                <div class="safety-topic">
                    <h3>用电安全</h3>
                    <p>了解正确用电方法，识别电器隐患，预防触电事故</p>
                    <a href="#electrical-safety">了解更多</a>
                </div>
            </section>

            <section class="announcements">
                <h2>最新安全通知</h2>
                <ul id="announcements-list"></ul>
            </section>

            <section class="news">
                <h2>安全新闻</h2>
                <div class="news-grid" id="news-list"></div>
            </section>

            <section class="knowledge-cards">
                <h2>安全知识卡片</h2>
                <div class="card">
                    <h3>如何识别网络诈骗</h3>
                    <p>1. 警惕陌生链接和附件</p>
                    <p>2. 不轻易泄露个人信息</p>
                    <p>3. 对要求转账的信息保持警惕</p>
                    <p>4. 使用强密码和双因素认证</p>
                    <p>5. 定期更新软件和系统</p>
                </div>
                <div class="card">
                    <h3>宿舍用电安全指南</h3>
                    <p>1. 不使用违规电器</p>
                    <p>2. 不过载使用插座</p>
                    <p>3. 及时关闭不用的电器</p>
                    <p>4. 定期检查电线是否老化</p>
                    <p>5. 远离水源使用电器</p>
                </div>
                <div class="card">
                    <h3>火灾逃生要点</h3>
                    <p>1. 保持冷静，迅速撤离</p>
                    <p>2. 用湿毛巾捂住口鼻</p>
                    <p>3. 贴地爬行，避开浓烟</p>
                    <p>4. 不乘坐电梯逃生</p>
                    <p>5. 记住安全出口位置</p>
                </div>
                <div class="card">
                    <h3>实验室安全准则</h3>
                    <p>1. 穿戴合适的防护装备</p>
                    <p>2. 了解紧急设备位置</p>
                    <p>3. 遵守操作规程</p>
                    <p>4. 不在实验室内饮食</p>
                    <p>5. 及时报告安全隐患</p>
                </div>
            </section>
        </div>
    </main>

    <footer>
        <div class="container">
            <p>联系我们：安全热线 123-456-7890 | 邮箱：safety@university.edu</p>
            <p>地址：XX省XX市XX大学学生安全中心</p>
            <p>&copy; 2023 学生安全中心 版权所有</p>
        </div>
    </footer>

    <button class="chat-button" id="chatButton">安全智能助手</button>
    <div class="chat-window" id="chatWindow">
        <h3>安全智能助手</h3>
        <div id="chatMessages"></div>
        <input type="text" id="userInput" placeholder="输入您的问题...">
        <button onclick="sendMessage()">发送</button>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Carousel functionality
            let currentSlide = 0;
            const slides = document.querySelectorAll('.carousel-item');

            function showSlide(n) {
                slides[currentSlide].classList.remove('active');
                currentSlide = (n + slides.length) % slides.length;
                slides[currentSlide].classList.add('active');
            }

            setInterval(() => showSlide(currentSlide + 1), 5000);

            // Announcements
            const announcements = [
                { title: "校园网络安全月活动", date: "2023-12-01", content: "参与线上安全知识竞赛，赢取丰厚奖品！" },
                { title: "冬季防火安全讲座", date: "2023-12-15", content: "专家讲解冬季防火要点，地点：大学生活动中心" },
                { title: "实验室安全检查通知", date: "2023-12-10", content: "各院系将进行实验室安全大检查，请做好准备" }
            ];

            const announcementsList = document.getElementById('announcements-list');
            announcements.forEach(item => {
                const li = document.createElement('li');
                li.innerHTML = `<strong>${item.title}</strong> (${item.date})<br>${item.content}`;
                announcementsList.appendChild(li);
            });

            // News
            const news = [
                { title: "我校荣获'安全校园'称号", date: "2023-11-30", content: "连续三年获此殊荣，彰显我校安全管理水平" },
                { title: "新版学生安全手册发布", date: "2023-12-05", content: "覆盖全面的安全指南，人手一册" },
                { title: "校园安全APP上线", date: "2023-12-08", content: "随时掌握安全资讯，一键求助功能备受好评" },
                { title: "安全知识竞赛圆满结束", date: "2023-12-12", content: "参与人数创新高，学生安全意识显著提升" }
            ];

            const newsList = document.getElementById('news-list');
            news.forEach(item => {
                const div = document.createElement('div');
                div.className = 'news-item';
                div.innerHTML = `
                    <h3>${item.title}</h3>
                    <p><small>${item.date}</small></p>
                    <p>${item.content}</p>
                `;
                newsList.appendChild(div);
            });

            // Chat functionality
            const chatButton = document.getElementById('chatButton');
            const chatWindow = document.getElementById('chatWindow');

            chatButton.addEventListener('click', function() {
                chatWindow.style.display = chatWindow.style.display === 'none' ? 'block' : 'none';
            });
        });

        function sendMessage() {
            const userInput = document.getElementById('userInput');
            const chatMessages = document.getElementById('chatMessages');
            const message = userInput.value;

            if (message.trim() !== '') {
                const userMessage = document.createElement('p');
                userMessage.textContent = `您: ${message}`;
                chatMessages.appendChild(userMessage);

                // Simulated AI response
                setTimeout(() => {
                    const aiMessage = document.createElement('p');
                    aiMessage.textContent = `安全助手: 感谢您的提问。我们会尽快为您解答有关"${message}"的问题。请记住，在遇到紧急情况时，请立即拨打校园安全热线。`;
                    chatMessages.appendChild(aiMessage);
                }, 1000);

                userInput.value = '';
            }
        }
    </script>
</body>
</html>